package com.zenitera.bigdata.catalog;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

public class Flink01_catalog_hive01 {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        String name = "myhive";
        String defaultDatabase  = "wangtingdb";
        String hiveConfDir = "E:/flink-0309/input";

        HiveCatalog hiveCatalog = new HiveCatalog(name, defaultDatabase , hiveConfDir);
        tableEnv.registerCatalog(name, hiveCatalog);

        tableEnv.useCatalog(name);
        tableEnv.useDatabase("wangtingdb");
        tableEnv.sqlQuery("select * from ods_user_info_inc limit 3;").execute().print();


    }
}
